package com.browan.background;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.View;

public class ScanView extends View
{

	private Bitmap background;

	public ScanView(Context context)
	{
		super(context);
	}

	public void setBackground(Bitmap bitmap)
	{
		release();
		this.background = bitmap;
	}

	public Bitmap getBacBitmap()
	{
		return this.background;
	}

	@Override
	protected void finalize() throws Throwable
	{
		release();
		super.finalize();
	}

	public void release()
	{
		if (null != background && !background.isRecycled())
		{
			background.recycle();
			background = null;
		}
	}

	@Override
	protected void onDraw(Canvas canvas)
	{
		if (null != background && !background.isRecycled())
			canvas.drawBitmap(background, 0, 0, null);
		super.onDraw(canvas);
	}
}
